package com.planet.utils.global;

import org.apache.logging.log4j.Level;

/**
 * Created by jiayazi on 17/9/20.
 */

// ***  异常封装：一般我们是要继承运行时异常，这样我们才能捕获到异常信息
public class DescribeException extends RuntimeException {
    private Integer code;
    private Level level;
    private String toast;


    /**
     * 继承exception，加入错误状态值
     * @param exceptionEnum
     */
    public DescribeException(ExceptionEnum exceptionEnum) {
        super(exceptionEnum.getMsg());
        this.code = exceptionEnum.getCode();
    }



    /**
     * 自定义错误信息
     * @param message
     * @param
     */
    public DescribeException(String message) {
        super(message);
        this.code = code;
    }

    /**
     * 自定义错误信息
     * @param message
     * @param code
     */
    public DescribeException(String message, Integer code) {
        super(message);
        this.code = code;
    }

    /**
     * 自定义错误信息(主要是给AssertUtils用的)
     * @param message
     * @param
     */
    public DescribeException(Level level, String toast, String message) {
        super(message);
        this.level = level;
        this.toast = toast;
        this.code = 1;
    }


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }
}
